﻿using System;
using System.Collections.Generic;
using System.Linq;
using ExpenseSystem.Common;
using ExpenseSystem.Fether;
using ExpenseSystem.Model;
using ExpenseSystem.Lor;

namespace ExpenseSystem.Fether
{
    public class PayFetcher : NormalFetcher<PayModel>,IDetailFetcher<PayModel>
    {
        public PayModel GetByCode(long site, string code, out string message)
        {
            IList<PayModel> result = List( site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out rows, Restrain.Eq("Code", code).And(Restrain.Eq("Avaliable", true)));
            if (result.Count > 0)
                return result.First();
            return null;
        }

        public IList<PayModel> ListByMainId(long site, long mainId, out string message,out int rows)
        {
            IList<PayModel> result = List( site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out rows, Restrain.Eq("CustomerId", mainId).And(Restrain.Eq("Avaliable", true)));
            return result;
        }

        public IList<PayModel> ListByOrder(long site, long mainId, out string message,out int rows)
        {
            IList<PayModel> result = List(site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out rows, Restrain.Eq("OrderId", mainId).And(Restrain.Eq("Avaliable", true)));
            return result;
        }

        public IList<PayModel> ListByAccounter(long site,long accounter,out string message,out int rows)
        {
            IList<PayModel> result = List(site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out rows, Restrain.Eq("Accounter", accounter).And(Restrain.Eq("Avaliable", true)));
            return result;
        }
        
    }
}
